<body>
    <input type="text">
    <button id="my-button">执行任务</button>
    <!-- box容器 -->
    <div id="box" style="height:500px;width:400px;overflow: auto;margin-top:24px;"></div>
</body>
<script type="module">
    import { runTask } from './index.js'
    console.log(123);
    // box容器溢出滚动
    const box = document.getElementById('box')
    for (let i = 0; i < 1000; i++) {
        const myText = document.createElement('h2')
        myText.innerText = i
        box.appendChild(myText)
    }
    // 执行任务
    const myButton = document.getElementById('my-button')
    myButton.addEventListener('click', async () => {
        console.time()
        for (let i = 100; i >= 0; i--) {
            await runTask(load) //用了优化
            // load() //没用优化
        }
        console.timeEnd()
    })
    function load() {
        const total = 150;
        for (let i = 0; i < total; i++) {
            console.log(i)
        }
    } 
</script>